package com.ct.gd.passport.common.util;

public class StringUtils {

	/***
	 * 返回长度对齐的整数字符串
	 * 
	 * @param value
	 * @param size
	 * @return
	 */
	public static final String getIntString(int value, int size) {
		String txt = Integer.toString(value);
		int len = size - txt.length();
		if (len > 0) {
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < len; i++) {
				sb.append('0');
			}
			sb.append(txt);
			return sb.toString();
		}
		return txt;
	}

	public static final int[] getDateFromStringToInt(String date) {
		String[] args = date.split("-");
		if (args != null && args.length == 3) {
			int[] as = new int[3];
			try {
				for (int i = 3; --i >= 0;) {
					as[i] = Integer.parseInt(args[i]);
				}
			} catch (Exception e) {
				e.printStackTrace();
				return null;
			}
			return as;
		}
		return null;
	}

}
